import { Button, Checkbox } from "antd";
import SelectIcon from "@/assets/images/add.png?jsx";
import { forwardRef, useState } from "react";
import type { IProgram, IProgramStatus } from "@/lib/types";

type ProgramSelectorProps = {
  onOpen: (matchModel: boolean) => void;
  value?: { program: IProgram; status: IProgramStatus[] };
  onChange?: (data: { program: IProgram; status: IProgramStatus[] }) => void;
};
const ProgramSelector = forwardRef<HTMLDivElement, ProgramSelectorProps>(
  function ProgramSelector(props, ref) {
    const { onOpen } = props;

    const [matchModel, setMatchModel] = useState(true);

    return (
      <div ref={ref}>
        <Button className="mr-4" onClick={() => onOpen(matchModel)}>
          <SelectIcon className="size-4" />
          选择
        </Button>
        <label className="cursor-pointer">
          <Checkbox
            checked={matchModel}
            onChange={(e) => setMatchModel(e.target.checked)}
          />
          &nbsp; 匹配型号
        </label>
      </div>
    );
  },
);

export default ProgramSelector;
